<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<body>
<div th:fragment="nav" >
    <nav class="navbar navbar-default">
        <div class="container navigation-nav">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
                        data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                    <span class="sr-only">知猿社区</span>
                </button>
                <a class="navbar-brand" href="/">知猿社区</a>
            </div>
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <form class="navbar-form navbar-left" action="/" method="get">
                    <div class="form-group input-group">
                        <input type="text" class="form-control" name="search" placeholder="搜索问题">
                        <span class="input-group-btn">
                            <button class="btn btn-default " type="submit">搜索</button>
                        </span>
                    </div>
                    <!--                    <button type="submit" class="btn btn-default">搜索</button>-->
                </form>
                <ul class="nav navbar-nav navbar-right">
                    <li th:if="${session.user != null}">
                        <a  href="/publish">提问</a>
                    </li>
                    <li><a href="/profile/replies">消息 <span class="badge navigation-message" th:if="${session.unreadCount}!=0" th:text="${session.unreadCount}"></span></a>
                    </li>
                    <li class="dropdown" th:if="${session.user != null}">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
                           aria-expanded="false">
                            <img th:src="${session.user.getAvatarUrl()}" class="navigation-avatarUrl img-rounded">
                            <span th:text="${session.user.getName()}"></span>
                            <span class="caret"></span>
                        </a>
                        <ul class="dropdown-menu">
                            <li><a class="glyphicon glyphicon-home" href="/profile/questions"> 我的主页</a></li>
                            <li><a class="glyphicon glyphicon-off" href="/logout"> 退出</a></li>
                        </ul>
                    </li>
                    <li th:if="${session.user == null}">
<!--                        <a th:href="@{https://github.com/login/oauth/authorize(client_id='d0d3ade7e00a78d3000f',redirect_uri=${#httpServletRequest.getServletContext().getAttribute('redirectUri')},scope='user',state=1)}">登录</a>-->
<!--                        <a th:href="@{https://github.com/login/oauth/authorize(client_id='d0d3ade7e00a78d3000f',redirect_uri=${#httpServletRequest.getRequestURL()+'callback'},scope='user',state=1)}">登录</a>-->
                        <a th:href="@{https://github.com/login/oauth/authorize(client_id='d0d3ade7e00a78d3000f',redirect_uri=${#httpServletRequest.getServletContext().getAttribute('githubRedirectUri')},scope='user',state=1)}">登录</a>
                    </li>
                </ul>
            </div>
        </div>
    </nav>
</div>
</body>
</html>